package com.allwees.bs.module.fms.rest;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.allwees.bs.core.modelbase.branch.BranchUser;
import com.allwees.bs.core.modelbase.vo.R;
import com.allwees.bs.module.core.dynamic.annotation.DynamicInject;
import com.allwees.bs.module.core.rest.BoCrudApi;
import com.allwees.bs.module.fms.entity.MerchantAccountLog;
import com.allwees.bs.module.fms.entity.MerchantWithdrawAccount;
import com.allwees.bs.module.fms.req.WithDrawQueryCondition;
import com.allwees.bs.module.fms.req.query.MerchantAccountLogQueryReq;
import com.allwees.bs.module.fms.service.MerchantAccountLogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商户账务流水记录
 *
 * @author yangylsky
 * @since 2020-01-06
 *
 */
@RestController
@RequestMapping("/backstage/api/fms/merchant_account_log")
public class MerchantAccountLogApi extends BoCrudApi<MerchantAccountLog, MerchantAccountLogService> {

    /**
     * 查询账务流水记录
     *
     * @param page
     * @param req
     * @return
     */
    @DynamicInject(key = "branchUuid",type= DynamicInject.Type.Retailer)
    @GetMapping("/page")
    public R page(Page<MerchantAccountLog> page,   MerchantAccountLogQueryReq req) {
        IPage<MerchantAccountLog> retPage = boService.findPage(page, req);
        return R.ok(retPage);
    }

    /**
     * 获取提现记录列表查询条件

     * @return
     */
    @GetMapping("/get_query_condition")
    public R getQueryCondition() {
        BranchUser user = getCurrentUser();
        WithDrawQueryCondition withDrawQueryCondition = new WithDrawQueryCondition();
        List<MerchantWithdrawAccount> merchantWithdrawAccountList = boService.findAllWithdrawAccount(user);
        withDrawQueryCondition.setCounterpartyAccountNoList(merchantWithdrawAccountList);
        return R.ok(withDrawQueryCondition);
    }
}
